package org.hagopa.games.moneypool.msgs.ContentTypes.service;

import java.nio.ByteBuffer;

import org.hagopa.games.moneypool.msgs.IMsgContent;



public class Version implements IMsgContent{
	
	private int Major = 0;
	private int SubVer = 0;

	public int getMajor() {
		return Major;
	}

	public void setMajor(int major) {
		Major = major;
	}

	public int getSubVer() {
		return SubVer;
	}

	public void setSubVer(int subVer) {
		SubVer = subVer;
	}

	
	public int getSize() {
		
		return (8);
	}
	
	
	public byte[] marshallToByte() {
		
		
		ByteBuffer dataArray = ByteBuffer.allocate(128);
	
		byte [] bytes = new byte[64];
		
		dataArray.putInt(this.Major);
		dataArray.putInt(this.SubVer);
		dataArray.rewind();
		System.out.println("Array Limit: " + dataArray.limit());
		
		dataArray.get(bytes,0,bytes.length);
		return bytes;
		
	}

	
	public boolean unmarshallFromByte(byte[] content) {
				
		ByteBuffer dataArray = ByteBuffer.wrap(content);
		if(null == dataArray)
		{
			return false;
		}
		dataArray.clear();
		//dataArray.rewind();
		this.Major = dataArray.getInt();
		this.SubVer = dataArray.getInt();
		return true;
	}

    public String getConcatContent() {
        String outstr = null;
        outstr = String.valueOf(this.Major) + String.valueOf(this.SubVer);
        return outstr;
    }

}
